package dao

import (
	"zk/global"
	"zk/internal/model"
)

func CreateUser(user *model.User) bool {
	if err := global.DB.Create(&user).Error; err != nil {
		return false
	}
	return true
}

func GetUserBy(name string) model.User {
	var result model.User
	if err := global.DB.Where("name = ?", name).Limit(1).Find(&result); err != nil {
		return model.User{}
	}
	return result
}
func GetUserByNameAndPassword(name, password string) bool {
	if err := global.DB.Where("name = ? and password = ?", name, password).Limit(1).Find(&model.User{}); err != nil {
		return false
	}
	return true
}
